package com.dofast.bt.mvp.presenter.basket;

import com.dofast.bt.adapter.AddressAdapter;
import com.dofast.bt.base.BaseApplication;
import com.dofast.bt.base.BaseMvpPresenter;
import com.dofast.bt.bean.AddressBean;
import com.dofast.bt.bean.GoodsBean;
import com.dofast.bt.mvp.view.activity.basket.EditAddressActivity;
import com.dofast.bt.mvp.view.activity.basket.EditAddressView;
import com.dofast.bt.mvp.view.activity.basket.PaymentActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/13.
 */

public class EditAddressPresenter extends BaseMvpPresenter<EditAddressView> implements IEditAddressPresenter {
    private AddressAdapter adapter = null;
    private List<AddressBean> list = null;


    @Override
    public void initData() {
        checkViewAttach();

        list = new ArrayList<AddressBean>();
        adapter = new AddressAdapter(list);
        mvpView.initAdapter(adapter);
        getData();
    }

    @Override
    public void newAddress() {

    }

    @Override
    public void selectAddress(int position) {
        mvpView.selectAddress(list.get(position));
//        if (list.get(position).isCheck()) {
//            for (AddressBean addressBean : list) {
//                addressBean.setCheck(false);
//            }
//        } else {
//            for (AddressBean addressBean : list) {
//                addressBean.setCheck(false);
//            }
//            list.get(position).setCheck(true);
//        }
//        adapter.notifyDataSetChanged();
    }

    /**
     * 获取地址列表
     */
    public void getData() {

        AddressBean bean = new AddressBean();
        bean.setName("杨新宇");
        bean.setAddress("厦门市思明区观音山" + 1 + "号楼" + 121);
        bean.setPhone("1340088080");
        list.add(bean);

        adapter.notifyDataSetChanged();
    }

    public void refresh(AddressBean addressBean) {
        list.add(addressBean);
        adapter.notifyDataSetChanged();
    }
}
